﻿Namespace OpenCL
    Public Class Program
        Public Property InternalPointer() As IntPtr
            Get
                Return m_InternalPointer
            End Get
            Private Set(ByVal value As IntPtr)
                m_InternalPointer = value
            End Set
        End Property
        Private m_InternalPointer As IntPtr

        Public Sub New(ByVal context As Context, ByVal ParamArray sources As String())
            Dim errorCode As Integer

            InternalPointer = OpenCLAPI.clCreateProgramWithSource(context.InternalPointer, sources.Length, sources, Nothing, errorCode)
        End Sub

        Protected Overrides Sub Finalize()
            Try
                OpenCLAPI.clReleaseProgram(InternalPointer)
            Finally
                MyBase.Finalize()
            End Try
        End Sub

        Public Sub Build(ByVal ParamArray devices As IntPtr())
            OpenCLAPI.clBuildProgram(InternalPointer, devices.Length, devices, Nothing, Nothing, IntPtr.Zero)
        End Sub
    End Class
End Namespace